// Created by WXX on 2021/11/13 14:14
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    bool detectCapitalUse(string word) {
        int cnt = 0;  // 大写字母数量
        for (char c : word) cnt += (c >= 'A' && c <= 'Z');
        return !cnt || cnt == word.size() || (cnt == 1 && word[0] >= 'A' && word[0] <= 'Z');
    }
};

int main() {

    cout << Solution().detectCapitalUse("USA") << endl;  // true
    cout << Solution().detectCapitalUse("FlaG") << endl;  // false

    return 0;
}
